package com.tiancheng.onecode.trade.model.request.order;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 退款参数
 *
 * @author kellen
 * @date 2024/11/25
 */
@Getter
@Setter
public class OpenRefundVO {
    /**
     * 用户id
     */
    @NotEmpty(message = "用户id不允许为空！")
    private String uid;
    /**
     * 主订单号
     */
    @NotEmpty(message = "订单id不允许为空！")
    private String orderId;
    /**
     * 退款订单号,前缀规则与下单订单号规则一致
     */
    @NotEmpty(message = "退款订单id不允许为空！")
    private String refundId;
    /**
     * 申请时间
     */
    @NotNull
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 退款原因
     */
    @NotEmpty
    private String refundReason;
    /**
     *子订单列表
     */
    @Valid
    @NotEmpty(message = "退款子订单信息不允许为空")
    private List<SubOrder> subOrders;

    @Getter
    @Setter
    public static class SubOrder {
        /**
         * 子订单号
         */
        @NotEmpty(message = "子订单号不允许为空！")
        private String subOrderId;
        /**
         * 退款订单号,前缀规则与下单订单号规则一致
         */
        @NotEmpty(message = "退款子订单id不允许为空！")
        private String subRefundId;
        /**
         * 子订单退款金额。注意：不传默认全部退款！
         */
        private Integer refundAmount;
    }
}
